package f.h.dragon.util;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * EmptyList: empty list
 *
 * @author Wenlong Meng(wenlong.meng@gmail.com)
 * @version 1.0 at 2012/06/15
 * @since 1.0
 */
public class EmptyList<E> implements List<E> {

	//Query Operations
	/**
     * Returns 0 - it is empty.
     *
     * @return  0 - it is empty
     */
	@Override
	public int size() {
		return 0;
	}

	/**
     * Returns <tt>true</tt> if this list contains no elements.
     *
     * @return <tt>true</tt> if this list contains no elements
     */
	@Override
	public boolean isEmpty() {
		return true;
	}

	/**
     * Returns <tt>true</tt> if this list isn't contains the specified element.
     *
     * @param o element whose presence in this list is to be tested
     * @return <tt>false</tt> if this list isn't contains the specified element
     */
	@Override
	public boolean contains(Object o) {
		return false;
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public Iterator<E> iterator() {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public Object[] toArray() {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public <T> T[] toArray(T[] a) {
		throw new UnsupportedOperationException();
	}

	// Modification Operations
	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public boolean add(E e) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public boolean remove(Object o) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public boolean containsAll(Collection<?> c) {
		return false;
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public boolean addAll(Collection<? extends E> c) {
		return false;
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public boolean addAll(int index, Collection<? extends E> c) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public boolean removeAll(Collection<?> c) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public boolean retainAll(Collection<?> c) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public void clear() {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public E get(int index) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public E set(int index, E element) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public void add(int index, E element) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public E remove(int index) {
		throw new UnsupportedOperationException();
	}

	/**
	 * @return -1 if this list does not contain the element
	 */
	@Override
	public int indexOf(Object o) {
		return -1;
	}

	/**
	 * @return -1 if this list does not contain the element
	 */
	@Override
	public int lastIndexOf(Object o) {
		return -1;
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public ListIterator<E> listIterator() {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public ListIterator<E> listIterator(int index) {
		throw new UnsupportedOperationException();
	}

	/**
	 * Thrown to indicate that the requested operation is not supported.
	 */
	@Override
	public List<E> subList(int fromIndex, int toIndex) {
		throw new UnsupportedOperationException();
	}

}
